package com.tobby.camelinaction.service;

import javax.sql.DataSource;

import org.apache.camel.CamelContext;
import org.springframework.jdbc.core.JdbcTemplate;

public class OrderCreateTable {

	public OrderCreateTable(CamelContext camelContext) {
		DataSource dataSource = camelContext.getRegistry()
				.lookupByNameAndType("myDataSource", DataSource.class);

		JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
		try {
			jdbcTemplate.execute("drop table riders_order");
		}
		catch (Exception e) {
			// ignore as the table may not exists
		}
		jdbcTemplate.execute(
				"create table riders_order (customer_id varchar(10), ref_no varchar(10), part_id varchar(10), amount varchar(10))");
	}

}
